<template>
    <div>
        <template v-if="list.length > 0">
        <div class="task"  v-for="(item,index) in list" :key="index">
            <div class="cont">
                <div class="ava">
                    <img src="~@/assets/list/docx.png"
                         class="img-ava">
                </div>
                <div>
                    <div class="title">{{item.about_file[0].title}}</div>
                    <div class="user-dete">
                        <div class="user">
                            <img src="~@/assets/list/person.png" class="u-img">
                            <div class="n1">{{item.pushName}}</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="dfx">
                <div class="buttom">
                    <div class="lq" v-if="type!=5" @click="down(index)">查看</div>
                    <div class="jxz" v-if="item.status!=1 && type!=5 && (admin_id === item.ad_id || department_id === 0)" @click="deletes(index)">删除</div>
                    <div class="jxz" v-if="item.status!=1 && type!=5 && (admin_id === item.ad_id || department_id === 0)" @click="edit(index)">编辑</div>
                </div>
            </div>
        </div>
        </template>
        <div v-else>
            <div class="list-none">
                <div class="list-img">
                    <img src="~@/assets/list/list-none.png" class="l-img"/>
                </div>
                <div class="l-str">~暂无数据~</div>
            </div>
        </div>
    </div>
</template>

<script>
import {ElMessage} from "element-plus";
import {useRouter} from "vue-router";

export default {
    props: ["type","list","total","admin_id","department_id"],
    name: "knowledge",
    data: () => ({
        circleUr: ""
    }),
    setup(props,context) {
        const router = useRouter();
        router.options.isAddDynamicMenuRoutes = false;
        const down = (index) => {
            let imagetype = props.list[index].about_file[0]['imagetype']
            let file =  props.list[index].about_file[0]['url']
            if (props.list.indexOf(imagetype) == -1) {
                window.open(file)
            } else {
                window.open('http://view.officeapps.live.com/op/view.aspx?src=' + escape(file))
            }
        }
        const deletes = (index) => {
            if(props.list[index].id === 0){
                ElMessage.error('参数错误，请刷新后重试');
                return false
            }
            context.emit('delkey',index);
        }
        const edit = (index) => {
            let id = props.list[index].id
            router.push({name: "repository-release-19",query: {'id':id}});
        }
        return {
            down,
            deletes,
            edit
        };
    }
};
</script>

<style lang="scss">
.task {
    display: flex;
    justify-content: space-between;
    padding-bottom: 25px;
    border-bottom: 1px solid #f5f5f5;
    margin-bottom: 15px;
    .ava {
        margin-right: 20px;
    }
    .title {
        color: #45484d;
        font-weight: 700;
        font-size: 15px;
        margin-bottom: 7px;
    }
    .desc {
        color: #8a9099;
        font-size: 13px;
        padding-top: 5px;
        white-space: nowrap; /* 因为设置了block，所以需要设置nowrap来确保不换行 */
        overflow: hidden; /* 超出隐藏结合width使用截取采用效果*/
        text-overflow: ellipsis; /* 本功能的主要功臣，超出部分的剪裁方式 */
        -o-text-overflow: ellipsis; /* 特定浏览器前缀 */
    }
    .cont {
        width: 50%;
        padding-top: 5px;
        display: flex;
    }
    .user {
        margin-top: 15px;
        display: flex;
    }
    .date {
        margin-top: 15px;
        display: flex;
        margin-left: 50px;
    }
    .u-img {
        width: 15px;
        height: 15px;
    }
    .n1 {
        font-size: 13px;
        color: #8a9099;
        margin-top: 1px;
        margin-left: 5px;
    }
    .str {
        font-size: 13px;
        color: #fb9180;
        margin-top: 1px;
        margin-left: 5px;
    }
    .user-dete {
        display: flex;
    }
    .int-img {
        width: 25px;
        height: 25px;
    }
    .price-cred {
        display: flex;
        margin-top: 8px;
        margin-left: 50px;
    }
    .inte {
        margin-left: 5px;
        color: #5c6066;
        font-size: 13px;
    }
    .buttom {
        margin-top: 22px;
        display: flex;
    }
    .lq {
        color: white;
        background: #6c91ed;
        font-size: 12px;
        padding: 10px;
        border-radius: 5px;
        cursor: pointer;
        margin-right: 5px;
        height: 14px;
    }
    .lq:active {
        background: #99a9d0;
    }
    .dfx {
        display: flex;
        justify-content: space-between;
    }
    .jxz {
        color: #6c91ed;
        background: white;
        font-size: 12px;
        padding: 8px;
        border-radius: 5px;
        cursor: pointer;
        text-align: center;
        border: 1px solid #6c91ed;
        height: 14px;
        margin-left: 15px;
    }
    .img-ava {
        width: 53px;
        height: 53px;
    }
}
</style>
